package com.zhuangjie.rider.controller;

import com.zhaungjie.base.conduit.R;
import com.zhuangjie.rider.dto.RiderSettingsUpdateDTO;
import com.zhuangjie.rider.entity.RiderSettings;
import com.zhuangjie.rider.service.RiderSettingsService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhuangjie
 * @since 2024-01-08
 */
@RestController
@RequestMapping("/rider-settings")
public class RiderSettingsController {

    @Autowired
    private RiderSettingsService riderSettingsService;

    @GetMapping("/query")
    @ApiOperation("查询骑手设置")
    public R queryRiderSettings() {
        return R.require(RiderSettings.class,riderSettingsService.queryCurrentRiderSettings());
    }

    @PostMapping("/update")
    @ApiOperation("更新系统派单状态")
    public R updateSystemDispatchStatus(@RequestBody RiderSettingsUpdateDTO riderSettingsUpdateDTO) {
        return R.capture(()->riderSettingsService.updateNonEmptyRiderSettingsAttributes(riderSettingsUpdateDTO));
    }
}
